const app = getApp()
import {
  HomeIndex
} from 'index-modal.js';
import {
  Config
} from '../../../utils/config.js';
var Function = require("../../../utils/function.js");
var index = new HomeIndex(); //实例化 首页 对象;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    head_img:'',
    money:0,
    id:'',
    members:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  
  },

  feedback(){
    let that = this;
    if (!wx.getStorageSync('members')) {
      wx.showModal({
        title: '提示',
        content: '你还未授权是否前往授权',
        success(res) {
          if (res.confirm) {
            wx.navigateTo({
              url: '/pages/auth/auth',
            })
          } else if (res.cancel) {
            wx.navigateBack({
              delta: 1
            })
          }
        }
      })
      return;
    }
    let data ={
      id: that.data.members
    }
    index.feedback(data,(res)=>{
      if(res.code == 200){
        that.setData({
          head_img: res.data.head_img,
          money: res.data.money,
          id:res.data.id,
          friend_money: res.data.friend_money,
        })
      }
    })
  },
  onShow:function(){
    let that=this;
    if (wx.getStorageSync('members')){
      that.setData({
        members: wx.getStorageSync('members')['id']
      })
    }
    this.feedback()
  },

 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    let that = this;
    if (res.from === 'button') {
      console.log("来自页面内转发按钮");
    }
    else {
      console.log("来自右上角转发菜单")
    }
    return {
      title: '好友送券', // 转发后 所显示的title
      path: '/pages/my/frend2/frend2?top_id=' + that.data.id // 相对的路径
    }
  }
})